<?php $this->load->view('common/header.php');?>
<div class="fxncre">
    
    <div class="fxnobj_wrap">
        <div class="fxnobj_wrap_left">
        <div class="fxncre_title">
        <h2 style="font-size:24px;"><!--<em class="icon-investment icon-db">债</em>--><?php echo $obj['title'];?>
<!--        <span style="float:right;font-size:14px;padding-right:20px;"><a href="/borrow/obj/--><?php //echo $obj['borrow_id'];?><!--.html">查看原借款项目</a></span></h2>-->
    </div>
            <div class="fxncre_list">
                <ul>
                    <li><p>转让价格（元）</p><em><span style="color: red"><?php echo $obj['discount_account'];?></span>元</em></li>
                    <li><p>年化收益</p><em><span style="color: red"><?php echo $obj['creditor_apr'];?>%</span></em></li>
                    <li><p>剩余时间</p><em><span style="color: red"><?php echo $obj['remaining_time_month'];?></span>个月<span style="color: red"><?php echo $obj['remaining_time_day'];?></span>天</em></li>
                </ul>
            </div>
            <div class="fxncre_xy">
                <ul>
                    <li><dd>转让债权：</dd><?php echo $obj['repayment_account'];?>元<dt></dt></li>
                    <li><dd>转让本金：</dd><?php echo $obj['account'];?>元<dt></dt></li>
                    <li><dd>折让金额：</dd><?php echo $obj['account']-$obj['discount_account'];?>元<dt></dt></li>
                    <li><dd>待收利息：</dd><?php echo $obj['wait_interest'];?>元<dt></dt></li>
                    <li><dd>还款方式：</dd><?php echo $borrow['style_name'];?><dt></dt></li>
                    <li><dd>原始期限：</dd><?php echo $borrow['time_limit'];?>个月<dt></dt></li>
                    <li><dd>原始年化：</dd><dt><?php echo $borrow['apr']?>%</dt></li>
                    <li><dd>转让进度：</dd>
                    <dt><div class="fxncre_safe_jd" title="<?php echo round($obj['discount_yes']/$obj['discount_account']*100,2);?>%">
                    <div class="fxncre_safe_jd_hover" style="width:<?php echo round($obj['discount_yes']/$obj['discount_account']*100,2);?>%;">
                   </div></div>
                     &nbsp;<span style=" float:right;color:#27b22d;"><?php echo round($obj['discount_yes']/$obj['discount_account']*100,2);?>%</span>
                    </dt></li>
                    <li><dd></dd><dt><a href="/borrow/obj/<?php echo $obj['borrow_id'];?>" target="_blank" class="f18" style="color: red;">查看原始项目</a></dt></li>
                </ul>
            </div>
        </div>
        <div class="fxnobj_wrap_right">

                <form id="buy_form">
                    <input type="hidden" name="id" value="<?php echo $obj['id'];?>" />
                    <ul>
                        <li><dd class="f16">可投资金额</dd><dd><em><?php echo $user_account['use_money'];?></em>元</dd></li>
                        <?php if(($obj['discount_account']-$obj['discount_yes']) == 0):?>
                            <li><dd class="f16">转让已完成</dd></li>
                        <?php else:?>
                            <li><dd class="f16">购买金额</dd>
                            <dd><input class="jeinput" style="width:130px;" id="money" type="text" name="money"></dd></li>
                            <?php if ($tuser_account['paypassword']==""){?>
                                <li>
                                    <dd class="f16">
                                        <a href="/user/paypwd/index.html" target="_blank">请先设置支付密码</a>
                                    </dd>
                                </li>
                            <?php }else{?>
                                <li><dd class="f16">支付密码</dd>
                                <dd><input class="jeinput" style="width:130px;" id="paypassword" type="password" name="paypassword" ></dd></li>
                            <?php }?>
                        <?php endif;?>
                        <li><dd class="f16">预期收益</dd><dd><em><?php echo $obj['expected_revenue'];?></em>元</dd></li>

                    </ul>
                </form>
                <div class="fxnbaobao_hover">
                    <?php if ($obj['fstatus']==2 && $obj['discount_account']>$obj['discount_yes']){?>
                        <a onclick="creditor_submit();" href="javascript:void(0);">立即投标</a>
                    <?php }elseif ($obj['fstatus']==2 && $obj['discount_account']<=$obj['discount_yes']){?>
                        <a href="javascript:void(0);">等待复审</a>
                    <?php }elseif ($obj['fstatus']==3){?>
                        <a href="javascript:void(0);">已完成</a>
                    <?php }?>
                </div>
        </div>
    </div>
</div>
<script>
    function creditor_submit(){
        var options = {
            url : '/borrow/creditor_transfer.html',
            dataType: "text",
            type:"post",
            success : function(msg) {
                $('#dialog').dialog({
                    modal:true,
                    title:'系统提示',
                    buttons:{"确定":function(){$(this).dialog("close");}},
                    close: function() {
                        location="/borrow/creditor/<?php echo $obj['id'];?>.html";
                    }
                });
                $("#msg").html(msg);
            }
        };
        $("#buy_form").ajaxSubmit(options);
        return false;
    }
</script>


<!-- Cre End -->

<div class="fxncre_wrap">
    <div class="fxnobj_tab">
        <ul>
<!--            <li id="li1" class="fxnobj_tab_hover" onclick="show(1);" style="cursor:pointer;">待收明细</li>-->
            <li id="li2" onclick="show(2);" style="cursor:pointer;">转让记录</li>
        </ul>
    </div>
<!--    <div id="div1" class="fxncre_info">-->
<!--        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="graytable1" style="text-align:center;">-->
<!--            <tr>-->
<!--                <th>期数</th>-->
<!--                <th>待收时间</th>-->
<!--                <th>待收总额</th>-->
<!--                <th>待收本金</th>-->
<!--                <th>待收利息</th>-->
<!--                <th>状态</th>-->
<!--            </tr>-->
<!--            --><?php
//            $cstatusArr = array(
//                0=>'待收',
//                1=>'已收',
//                2=>'已取消',
//            );
//            ?>
<!--            --><?php //foreach ($coll_list as $val){?>
<!--                <tr --><?php //if ($val['fstatus']==0){?><!-- style="color:red;" --><?php //}else{?><!-- style="color:green;" --><?php //}?><!-->
<!--                    <td>--><?php //echo $val['forder']+1;?><!--</td>-->
<!--                    <td>--><?php //echo date('Y-m-d',$val['repay_time']);?><!--</td>-->
<!--                    <td>--><?php //echo $val['repay_account'];?><!--</td>-->
<!--                    <td>--><?php //echo $val['capital'];?><!--</td>-->
<!--                    <td>--><?php //echo $val['interest'];?><!--</td>-->
<!--                    <td>--><?php //echo $cstatusArr[$val['fstatus']];?><!--</td>-->
<!--                </tr>-->
<!--            --><?php //}?>
<!--        </table>-->
<!--    </div>-->
    <div id="div2" class="fxncre_info">
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="funds graytable">
            <tbody>
            <tr class="title">
                <th width="20%">用户名</th>
                <th width="20%">申购金额</th>
                <th width="20%">申购时间</th>
                <th width="20%">状态</th>
            </tr>
            <?php
            $logstatusArr = array(
                1=>'正在申购',
                2=>'申购完成',
                3=>'已还完',
                4=>'已取消',
            );
            ?>
            <?php foreach ($buyers as $val){?>
                <tr>
                    <td><?php echo $val['username'];?></td>
                    <td><?php echo $val['discount_buy'];?></td>
                    <td><?php echo date('Y-m-d H:i:s',$val['add_time']);?></td>
                    <td><?php echo $logstatusArr[$val['fstatus']];?></td>
                </tr>
            <?php }?>
            </tbody>
        </table>
    </div>
</div>
<script type="text/javascript">
    function show(documentId){
        for(var i=1;i<5;i++){
            if(documentId==i){
                document.getElementById('div'+i).style.display='';
                document.getElementById('li'+i).className='fxnobj_tab_hover';
            }else{
                document.getElementById('div'+i).style.display='none';
                document.getElementById('li'+i).className='';
            }
        }
    }
</script>
<!-- Cre_Wrap End -->
<div class="fxncre_wrap">
    <h2 class="txt-b" style="font-size:14px;">转让说明</h2>
    <div class="fxncre_info"><?php echo nl2br($obj['content']);?></div>
</div>
<!-- Cre_Wrap End -->
<?php $this->load->view('common/footer.php');?>
